import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import tsconfigPaths from 'vite-tsconfig-paths';

// https://vite.dev/config/
import path from 'node:path';

const DS_ROOT = path.resolve(__dirname, '../src/data-structures');
const ROOT_PARENT = path.resolve(__dirname, '..');

export default defineConfig({
  plugins: [react(), tsconfigPaths()],
  resolve: {
    alias: [{ find: '@ds', replacement: DS_ROOT }],
  },
  server: {
    fs: {
      // 允许访问上一级目录以导入现有数据结构代码（使用绝对路径更稳妥）
      allow: [ROOT_PARENT],
    },
  },
});
